* Nicolai Petrovsky
* nicolai.petrovsky@uky.edu

* This do-file generates the variables for and runs the 
* analysis reported in the Profiroiu, Petrovsky, and 
* Jennings article "Does Pendleton's Premise Hold in New 
* And Old Democracies Alike? Politicization and Performance 
* in the U.S. and Central and Eastern Europe." 
* Transylvanian Review of Administrative 
* Sciences 37 (October): 143-154

* Stata version 11.2
* last modified February 28, 2014

* Data file required:
* partredux.dta

* Please copy this do-file and the data file into a
* directory on your hard drive.
* Then, please use Stata's command
* cd
* to change to that directory.
* Now you can run this do-file.

* How to find the result(s) you are interested in: 

* Since there is a lot of material in this do-file, you can 
* find the results for the items that most interest you in 
* the following way: 
* After running this do-file, view the log-file 
* (TRAS2012.smcl) and search within it for "Page 148" if 
* you'd like to see a result from page 148 in the article; 
* same for all other pages with results.  
* (In order to search within the log-file, click the 
* search button on the top left-hand side of the Stata viewer.)

clear
clear matrix
version 11.2
set more off
set memory 100m
set scheme s1mono

* Open a log and allow for replacement
log using TRAS2012, replace

* Open data
use partredux.dta
save workfile, replace

* Obtain the information required for the various transition matrices
*******

* Page 147: Changes in manager
tab same_manager

* Changes in appointment type

gen appttypechg = _2nd_appttype - appttype
drop if appttypechg == .

* Page 147: Career to political (i.e. CA --> NA|PAS|XS|schC)
gen car2pol = 0 if appttypechg ~= .
replace car2pol = 1 if appttypechg > 0 & appttype == 1 & appttypechg ~= .
tab car2pol
list department bureau program manager appttype _2nd_part_manager _2nd_appttype if car2pol == 1

* Page 147: Political to career (i.e. NA|PAS|XS|schC --> CA)
gen pol2car = 0 if appttypechg ~= .
replace pol2car = 1 if appttypechg < 0 & (appttype > 1 & appttype ~= .) & appttypechg ~= .
tab pol2car
list department bureau program manager appttype _2nd_part_manager _2nd_appttype if pol2car == 1

* Page 148, Table 1: Transition Matrix for Programs Led 
* by Career Officials at both Assessments
tab programgrade _2nd_part_grade if car2pol == 0 & pol2car == 0 & appttype == 1

* Page 148, Table 2: Transition Matrix for Programs Led 
* by Political Appointees at both Assessments
tab programgrade _2nd_part_grade if car2pol == 0 & pol2car == 0 & (appttype > 1 & appttype ~= .)

* Page 147: Changes in PART ratings

gen PARTchange = _2nd_part_grade - programgrade
assert PARTchange ~= .

* PART rating down
gen PARTdown = 1 if PARTchange < 0
replace PARTdown = 0 if PARTchange >= 0 & PARTchange ~= .
tab PARTdown
list bureau program programgrade _2nd_part_grade if PARTdown == 1

* Page 147: PART rating unchanged
gen PARTsame = 1 if PARTchange == 0
replace PARTsame = 0 if PARTchange ~= 0 & PARTchange ~= .
tab PARTsame

* PART rating up
gen PARTup = 1 if PARTchange > 0 & PARTchange ~= .
replace PARTup = 0 if PARTchange <= 0
tab PARTup

* Test whether politicization predicts PART changes
*******

* Generate auxiliary variables

* Dummy for political appointee in both periods
gen bothpolitical = 0 if appttypechg ~= .
replace bothpolitical = 1 if (appttype > 1 & appttype ~= .) /*
*/ & (_2nd_appttype > 1 & _2nd_appttype ~= .)

* Budget change between evaluations
gen budgetchange = (funding_fy08 - actualbudinevyr) / 1000

* Page 149, Table 3: Predicting PART ratings and changes 
* in PART ratings
reg _2nd_part_grade programgrade bothpolitical car2pol pol2car budgetchange, cluster(bureau)
reg PARTup programgrade bothpolitical car2pol pol2car budgetchange, cluster(bureau)
reg PARTdown programgrade bothpolitical car2pol pol2car budgetchange, cluster(bureau)

* Page 149, footnote 2: "The results are substantively 
* unchanged if an ordered logit estimator is used for the 
* first specification and binary logit for the second and 
* the third, but using OLS avoids the requirement to 
* compute marginal effects.  Also, whether we use 
* Huber-White standard errors (with or without adjusting 
* for clustering on the bureau that houses a program) or 
* regular OLS standard errors makes no substantive difference."

ologit _2nd_part_grade programgrade bothpolitical car2pol pol2car budgetchange, cluster(bureau)
logit PARTup programgrade bothpolitical car2pol pol2car budgetchange, cluster(bureau)
logit PARTdown programgrade bothpolitical car2pol pol2car budgetchange, cluster(bureau)

reg _2nd_part_grade programgrade bothpolitical car2pol pol2car budgetchange
reg PARTup programgrade bothpolitical car2pol pol2car budgetchange
reg PARTdown programgrade bothpolitical car2pol pol2car budgetchange

clear
clear matrix
erase workfile.dta
log close
exit

* You can now view a record of all operations and results 
* in the log file.
